<include file="Common:header" />
<body>
<!--面包屑导航 开始-->
<div class="crumb_warp">
    <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
    <i class="fa fa-home"></i><a href="{:U(MODULE_NAME.'/Index/info')}"> 首页</a> &raquo; 文章回收站
</div>
<!--面包屑导航 结束-->

<!--结果页快捷搜索框 开始-->
<div class="search_wrap">
    <form action="{:U(MODULE_NAME.'/Article/trach')}" method="post">

        <table class="search_tab">
            <tr>
                <th width="120">选择分类:</th>
                <td>
                    <select name="cate_id">
                        <foreach name="cate" item="v">
                            <option value="{$v.cate_id}">{$v._cate_name}</option>
                        </foreach>
                    </select>
                </td>
                <th width="70">关键字:</th>
                <td><input type="text" name="keywords" placeholder="关键字"></td>
                <td><input type="submit" name="sub" value="查询"></td>
            </tr>
        </table>
    </form>
</div>
<!--结果页快捷搜索框 结束-->

<!--搜索结果页面 列表 开始-->
<form action="#" method="post">
    <div class="result_wrap">
        <div class="result_title">
            <h3>快捷操作</h3>
        </div>
        <!--快捷导航 开始-->
        <div class="result_content">
            <div class="short_wrap">
                <a href="{:U(MODULE_NAME.'/Article/add')}"><i class="fa fa-plus"></i>新增文章</a>
                <a href="javascript:;" onclick="delArticleAll();"><i class="fa fa-recycle"></i>批量删除</a>
                <a href="{:U(MODULE_NAME.'/Article/trach')}"><i class="fa fa-refresh"></i>刷新页面</a>
            </div>
        </div>
        <!--快捷导航 结束-->
    </div>

    <div class="result_wrap">


        <div class="result_content">
            <table class="list_tab">
                <tr>
                    <th class="tc" width="5%"><input type="checkbox" name="ids"></th>
                    <th class="tc">ID</th>
                    <th>标题</th>
                    <th>栏目</th>
                    <th>点击</th>
                    <th>发布人</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                <foreach name="article" item="v">
                <tr>
                    <td class="tc"><input type="checkbox" name="art_id" id="art_id" value="{$v.art_id}"></td>
                    <td class="tc">{$v.art_id}</td>
                    <td><a href="#">{$v.art_title}</a></td>
                    <td>{$v.cate_name}</td>
                    <td>{$v.art_view}</td>
                    <td>{$v.art_editor}</td>
                    <td>{$v.art_time|date='Y-m-d',###}</td>
                    <td>
                        <a href="javascript:;" onclick="recovery({$v['art_id']})">恢复</a>
                        <a href="javascript:;" onclick="delArticle({$v['art_id']})">删除</a>
                    </td>
                </tr>
                </foreach>
            </table>

            <div class="page_list">

            </div>
        </div>
    </div>
</form>
<!--搜索结果页面 列表 结束-->
<script>




    //异步批量删除
    function delArticleAll(art_id){
        var artid="";
        $("input[name='art_id']:checkbox").each(function(){
            if($(this).attr("checked")){
                artid += $(this).val()+","
            }
        })
        //layer询问框
        layer.confirm('确定删除所需文章？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:U(MODULE_NAME."/Article/deleteAll")}',{'art_id':artid},function(data){
                if(data.status==1){
                    layer.msg(data.info);
                    location.href=location.href;
                }else{
                    layer.msg(data.info);
                }
            });
        });
    }


    //异步删除文章
    function delArticle(art_id){

        //layer询问框
        layer.confirm('您确定要删除这篇文章吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:U(MODULE_NAME."/article/destroy")}',{'art_id':art_id},function(data){
                if(data.status==1){
                    layer.msg(data.info);
                    location.href=location.href;
                }else{
                    layer.msg(data.info);
                }
            });
        });
    }

    function recovery(art_id){

        //layer询问框
        layer.confirm('您确定要恢复这篇文章吗？？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:U(MODULE_NAME."/article/recovery")}',{'art_id':art_id,'stats':0},function(data){
                if(data.status==1){
                    layer.msg(data.info);
                    location.href=location.href;
                }else{
                    layer.msg(data.info);
                }
            });
        });
    }
</script>
</body>
</html>